package com.hmsm.sys.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hmsm.server.base.BaseService;
import com.hmsm.server.util.QueryResult;
import com.hmsm.sys.dao.DynamicCipherCardDao;
import com.hmsm.sys.po.DynamicCipherCard;
import com.hmsm.sys.po.RoleInfo;
import com.hmsm.sys.po.UserInfo;

@Service
public class DynamicCipherCardService extends BaseService<DynamicCipherCard, Integer, UserInfo, RoleInfo> {

	public DynamicCipherCardDao getDynamicCipherCardDao() {
		return (DynamicCipherCardDao) baseDao;
	}

	@Resource
	public void setDynamicCipherCardDao(DynamicCipherCardDao dynamicCipherCardDao) {
		this.baseDao = dynamicCipherCardDao;
	}

	/**
	 *  @Description:
	 *  @ClassName  :com.hmsm.sys.service.DynamicCipherCardService.java
	 *  @Author     :yaosq
	 *  @CreateDate :2013-11-15 下午01:24:42  
	 **/
	public List<DynamicCipherCard> getDynamicInfo() {
		return this.getDynamicCipherCardDao().getDynamicInfo();
	}
	
	/**
	  * 
	  *  @Description:修改sn密令信息分配标志
	  *  @MethodName :updateSNInfo
	  *  @Author     :yaosq
	  *  @CreateDate :2013-11-15 下午04:30:20 
	  *  @param sn
	  *
	  */
	public void updateSNInfo(Integer sn){
		 this.getDynamicCipherCardDao().updateSNInfo(sn);
	 }
	 
	 /**
	  * 
	  *  @Description:解除绑定
	  *  @MethodName :jcSNInfo
	  *  @Author     :yaosq
	  *  @CreateDate :2013-11-15 下午06:35:42 
	  *  @param sn
	  *
	  */
	public void jcSNInfo(Integer sn){
		 this.getDynamicCipherCardDao().jcSNInfo(sn);
	 }
	 
	 /**
		 *  @Description:记录条数
		 *  @MethodName :getDynamicInfoCount
		 *  @Author     :fengt
		 *  @CreateDate :2013-11-19 下午02:07:27 
		 *  @return
		 **/
		public int getDynamicInfoCount(int snCode, int isBinding){
			return getDynamicCipherCardDao().getDynamicInfoCount(snCode, isBinding);
		}
		
		/**
		 *  @Description:
		 *  @MethodName :getDynamicInfoList
		 *  @Author     :fengt
		 *  @CreateDate :2013-11-19 下午02:08:58 
		 *  @param snCode
		 *  @param isBinding
		 *  @return
		 **/
		public QueryResult<DynamicCipherCard> getDynamicInfoList(Integer index, Integer maxresult, Integer totalPage, int snCode, int isBinding, Integer count){
			if (index == null || maxresult == null || totalPage == null) {
				return null;
			}
			if (index<=0) {
				index = 1;
			}
			if(index>=totalPage){
				index = totalPage;
				if (index==0) {
					index=1;
				}
			}
			QueryResult<DynamicCipherCard> list = new QueryResult<DynamicCipherCard>();
			list.setResultlist(getDynamicCipherCardDao().getDynamicInfoList(index, maxresult, snCode, isBinding));
			list.setAllPages(totalPage);
			list.setNowPageNumber(index);
			list.setNowViewRecordNumber(list.getResultlist().size());
			list.setPerPageNumber(maxresult);
			list.setTotalrecord(count);
			return list;
		}
}
